<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Global</title>
    
    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Global</h1>
    
    



<section>
    
<header>
    <h2>
    
    </h2>
    
</header>  

<article>
    <div class="container-overview">
    
    
    
        
        
        
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>

        
        
    
    </div>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
        <h3 class="subsection-title">Methods</h3>
        
        <dl>
            
<dt>
    <h4 class="name" id="addSourceFolder"><span class="type-signature"></span>addSourceFolder<span class="signature">()</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Add source folders to EasyNode, EasyNode will find class or namespace from source folders. Default source folder of EasyNode is 'src'
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>...</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>
            
            
            
            
            
            <td class="description last">*, Source folder, relative to the home directory of EasyNode</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line280">line 280</a>
    </li></ul></dd>
    
    
    
    
    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="global.html#using">using</a></li>
        
            <li>resolveNamespace</li>
        </ul>
    </dd>
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>addSourceFolder('test');</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="arg"><span class="type-signature"></span>arg<span class="signature">(name)</span><span class="type-signature"> &rarr; {String}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Get command line argument
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>name</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>
            
            
            
            
            
            <td class="description last">*, Name of command line argument</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line99">line 99</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    Value of command line argument
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">String</span>


	</dd>
</dl>

        
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>nodejs main.js --easynode-home=/home/zlbbq/EasyNode
console.log(arg('easynode-home'));           //print: /home/zlbbq/EasyNode</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="config"><span class="type-signature"></span>config<span class="signature">(name)</span><span class="type-signature"> &rarr; {String}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Get configuration value, configuration file is $EasyNode/etc/EasyNode.conf. Note : if a command line argument has the same
name as configuration item, the configuration item in EasyNode.conf is ignored, means, the return value is equal to arg().
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>name</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>
            
            
            
            
            
            <td class="description last">*, Name of configuration item</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line131">line 131</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    Value of configuration item or null if configuration item not exists
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">String</span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="extend"><span class="type-signature"></span>extend<span class="signature">()</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        This function is a shortcut to 'extend' of underscore.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line82">line 82</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code> var o = { a : 'a'};
 extend(o, {b : 'b'});
 console.log(JSON.stringify(o));             //print: {a : 'a', b: 'b'}</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="home"><span class="type-signature"></span>home<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Get the home directory of EasyNode. By default, returns the parent directory of  process.pwd(), but also you can set a command
line argument to specify where the home directory of EasyNode is.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line49">line 49</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    Home directory of EasyNode
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">String</span>


	</dd>
</dl>

        
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>console.log(home());              //print: /home/zlbbq/EasyNode,  make sure your working directory is $EasyNode/bin

//if you start EasyNode and passed command line argument 'easynode-home'
nodejs /home/zlbbq/EasyNode/bin/main.js --easynode-home=/home/zlbbq/EasyNode

console.log(home());             //print: /home/zlbbq/EasyNode</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="namespace"><span class="type-signature"></span>namespace<span class="signature">(name)</span><span class="type-signature"> &rarr; {String}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Get namespace of source code, Note :  the source code folder is $EasyNode/src/
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>name</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>
            
            
            
            
            
            <td class="description last">*, pass __dirname or __filename</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line167">line 167</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    Namespace descriptor
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">String</span>


	</dd>
</dl>

        
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>//supposing the following code is written in file $EasyNode/src/easynode/util/StringUtil.js

console.log(namespace(__filename));  //print easynode.util.StringUtil
console.log(namespace(__dirname));   //print easynode.util</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="real"><span class="type-signature"></span>real<span class="signature">(p)</span><span class="type-signature"> &rarr; {String}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Get the home directory of EasyNode. By default, returns the parent directory of  process.pwd(), but also you can set a command
line argument to specify where the home directory of EasyNode is.
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>p</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>
            
            
            
            
            
            <td class="description last">Relative path to any resource in EasyNode, relative to the home directory of EasyNode.</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line66">line 66</a>
    </li></ul></dd>
    
    
    
    
    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="global.html#home">home</a></li>
        </ul>
    </dd>
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    Absolute path of passed resource.
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">String</span>


	</dd>
</dl>

        
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>console.log(real('src/');              //print: /home/zlbbq/EasyNode/src</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="resolveNamespaces"><span class="type-signature"></span>resolveNamespaces<span class="signature">()</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Resolve namespaces from source folders. EasyNode always resolve 'src' as a source folder.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line312">line 312</a>
    </li></ul></dd>
    
    
    
    
    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="global.html#using">using</a></li>
        
            <li><a href="global.html#addSourceFolder">addSourceFolder</a></li>
        </ul>
    </dd>
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>addSourceFolder('test');
addSourceFolder('test', 'app');
resolveNamespaces();</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="trim"><span class="type-signature"></span>trim<span class="signature">(s)</span><span class="type-signature"> &rarr; {String}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Trim a string and return new one. If pass nothing or null to this function, returns an empty string
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>s</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>
            
            
            
            
            
            <td class="description last">*, ABC</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line25">line 25</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    <h5>Throws:</h5>
    
            

<dl>
    <dt>
        <div class="param-desc">
        When parameter s is not a string
        </div>
    </dt>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type">TypeError</span>


            </dd>
        </dl>
    </dt>
</dl>


        
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    Trimmed string
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">String</span>


	</dd>
</dl>

        
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>var s = '   abc   ';
console.log(trim(s));              //print: abc
console.log(trim(null));         //print: ''-> a blank string</code></pre>

    
</dd>

        
            
<dt>
    <h4 class="name" id="using"><span class="type-signature"></span>using<span class="signature">(name)</span><span class="type-signature"> &rarr; {Object}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Use a class or use classes of a namespace
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>name</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>
            
            
            
            
            
            <td class="description last">*, Class name or namespace name</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>1.0</dd>
    

    
    
    
    
    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>zlbbq</li>
        </ul>
    </dd>
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="globals.js.html">globals.js</a>, <a href="globals.js.html#line195">line 195</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    Namespace instance or node export instance
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">Object</span>


	</dd>
</dl>

        
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>//supposing the following code is written in file $EasyNode/src/easynode/util/StringUtil.js

using('easynode.Logger');
var logger = easynode.Logger.forFile(__filename);
logger.debug('hello');

var Logger = using('easynode.Logger');
Logger.forFile(__filename).debug('hello');


var en = using('easynode.*');
en.Logger.forFile(__filename).debug('hello');</code></pre>

    
</dd>

        </dl>
    
    
    
    
    
</article>

</section>  




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="easynode.Logger.html">Logger</a></li></ul><h3>Namespaces</h3><ul><li><a href="easynode.html">easynode</a></li><li><a href="easynode.framework.html">framework</a></li><li><a href="easynode.framework.server.html">server</a></li><li><a href="easynode.test.html">test</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addSourceFolder">addSourceFolder</a></li><li><a href="global.html#arg">arg</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#extend">extend</a></li><li><a href="global.html#home">home</a></li><li><a href="global.html#namespace">namespace</a></li><li><a href="global.html#real">real</a></li><li><a href="global.html#resolveNamespaces">resolveNamespaces</a></li><li><a href="global.html#trim">trim</a></li><li><a href="global.html#using">using</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Sat May 09 2015 09:08:52 GMT+0800 (CST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>